#include "modify.h"
#include "ui_modify.h"
#include <QPainter>
extern LinkList<Node>stu;
modify::modify(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::modify)
{
    ui->setupUi(this);
    setWindowTitle("修改学生信息");
}

modify::~modify()
{
    delete ui;
}

void modify::on_m_return_button_clicked()
{
    mainWindow*mWin=new mainWindow;
    mWin->show();
    delete this;
}

void modify::on_m_ok_button_clicked()
{
    QString a=ui->mID->text();
    int b=stu.FindId(a);
    if(b==0)
    {
        QMessageBox::warning(this,"警告","无此学生");
        return;
    }
    QString name = this->ui->m_name->text();
    QString id = this->ui->m_id->text();
    QString classnu = this->ui->m_name_2->text();
    QString roomnu = this->ui->m_name_3->text();
    QString sex=NULL ;
    if(this->ui->m_sexbutton1->isChecked())
    {
     sex = this->ui->m_sexbutton1->text();
    }
    if(this->ui->m_sexbutton2->isChecked())
    {
     sex = this->ui->m_sexbutton2->text();
    }
    QString faculty=this->ui->m_faculty->currentText();
    if(name==NULL||id==NULL||sex==NULL||faculty==NULL)
    {
        QMessageBox::warning(this,"警告","信息未完善");
        return;
    }
    Node x(id,name,sex,faculty,roomnu,classnu);
    stu.ModifyData(b,x);
     QMessageBox::warning(this,"提示","修改成功");
}
void modify::paintEvent(QPaintEvent *)
{
   QPainter p(this);//创建画家对象p
    //绘图操作
    p.drawPixmap(rect(),QPixmap(":/new/prefix1/IMG_20210819_144731.jpg"));

}
